import request from './request.js'
import UNI_APP from '@/.env.js'

// 获取注册验证码
export function sendCodeApi(data) {
	return request({
		url: 'user/sendRegisterCode?phone=' + data.phone,
		method: 'POST',
	})
}

// 校验注册验证码
export function checkRegisterCode(data) {
	return request({
		url: 'user/checkRegisterCode?phone=' + data.phone + '&code=' + data.code,
		method: 'POST',
	})
}

// 获取注册助记词
export function getWordsApi(data) {
	return request({
		url: 'user/getWords?langueCode=' + data.langueCode,
		method: 'GET',
	})
}

// 注册
export function registerApi(data) {
	return request({
		url: 'user/register',
		data,
		method: 'POST',
	})
}

// 本地密码登录登录
export function psdLoginApi(data) {
	return request({
		url: 'user/LocaLogin',
		data,
		method: 'POST',
	})
}

// 助记词登录
export function worldLoginApi(data) {
	return request({
		url: 'user/wordsLogin',
		data,
		method: 'POST',
	})
}

// 手机号或编号获取用户
export function findUserApi(data) {
	return request({
		url: 'user/getUserByPhoneOrNum?phone=' + data.phone,
		data,
		method: 'GET',
	})
}

// id获取用户
export function findUserByIdApi(data) {
	return request({
		url: 'user/getUserById?id=' + data.id,
		data,
		method: 'GET',
	})
}

// 获取本人 用户信息
export function getMeUserAPI(data) {
	return request({
		url: 'user/getUserInfo',
		data,
		method: 'GET'
	})
}

// 添加好友
export function addFriendApi(data) {
	return request({
		url: 'friend/add?friendId=' + data.friendId,
		method: 'POST',
	})
}

// 好友列表
export function friendListApi(data) {
	return request({
		url: 'friend/list',
		method: 'GET',
	})
}

// 发送消息
export function sendMsgApi(data) {
	return request({
		url: 'message/private/send',
		data,
		method: 'POST',
	})
}

// 拉取离线信息
export function pullOfflineMsgApi(data) {
	return request({
		url: 'message/private/pullOfflineMessage?minId=' + data.minId,
		method: 'GET',
	})
}

// 查找好友信息
export function friendFindApi(data) {
	return request({
		url: 'friend/find/' + data.id,
		method: 'GET',
	})
}

// 查找群聊历史信息
export function groupHistoryApi(data) {
	return request({
		url: 'message/group/history?groupId=' + data.groupId + '&page=' + 1 + '&size=' + 20,
		method: 'GET',
	})
}


// 发红包
export function sendRedPacketApi(data) {
	return request({
		url: 'perRedPacketInfo/sendRedPacket',
		data,
		method: 'POST',
	})
}

// 抢红包 , 未拆开
export function snatchRedPackerApi(data) {
	return request({
		url: 'perRedPacketInfo/snatchRedPacket?redPacketId=' + data.id,
		method: 'POST',
	})
}

// 抢红包 , 拆开
export function openRedPackrApi(data) {
	return request({
		url: 'perRedPacketInfo/openRedPacket?redPacketId=' + data.id,
		method: 'POST',
	})
}

// 绑定OTC账号
export function bindAccountApi(data) {
	return request({
		url: "user/bindAccount?phone=" + data.phone + '&password=' + data.password + '&accountPassword=' + data.accountPassword + '&code=' + data.code + '&type=' + data.type,
		data,
		method: "POST"
	})
}

// 刷新token
export function refreshToken(data) {
	return request({
		url: "user/refreshToken?refreshToken=" + data,
		method: 'POST',
	})
}


// 获取绑定OTC账号验证码
export function sendBindCodeApi(data) {
	return request({
		url: "user/sendBindCode?phone=" + data.phone,
		data,
		method: "POST"
	})
}

// 获取钱包信息
export function getWalletInfoApi(data) {
	return request({
		url: "wallet/getByUserId",
		method: "GET"
	})
}

// 获取委托参数
export function getEntrustParame(data) {
	return request({
		url: 'mateTrade/getComputeParameter',
		data: data,
		method: 'GET'
	})
}
// 获取用户资金(碳)
export function getUserAccount(data) {
	return request({
		url: 'user/getUserAccount',
		data: data,
		method: 'GET',
	})
}

// 发布委托
export function issueEntrust(data) {
	return request({
		url: 'mateTrade/entrust',
		data: data,
		method: 'POST'
	})
}
// 获取待交易列表
export function getMateTrade(data) {
	return request({
		url: 'mateTrade/getMateTrade',
		data: data,
		method: 'GET'
	})
}

// 获取已完成订单列表
export function getTradeOrder(data) {
	return request({
		url: 'mateTrade/getTradeOrder',
		data: data,
		method: 'GET'
	})
}

// 取消委托
export function cancelMateTrade(data) {
	return request({
		url: 'mateTrade/cancelMateTrade',
		data: data,
		method: 'POST'
	})
}

// 最新交易记录
export function lastTrade(data) {
	return request({
		url: 'latestTrade/pageLatestTrade',
		data: data,
		method: 'GET'
	})
}

// 提现申请
export function withdrawApply(data) {
	return request({
		url: "wapply/withdrawApply?amount=" + data.amount + '&address=' + data.address + '&password=' + data
			.password,
		// data: data,
		method: 'POST'
	})
}

// 提现记录
export function wapplyRecord(data) {
	return request({
		url: 'wapply/list',
		data: data,
		method: 'GET'
	})
}

// 好友转账
export function friendTransfer(data) {
	console.log(data);
	return request({
		// url: 'wallet/friendTransfer',
		url: "wallet/friendTransfer?amount=" + data.amount + '&friendId=' + data.friendId + '&password=' + data
			.password,
		// data: data,
		method: 'POST'
	})
}

// 资金列表
export function fundRecord(data) {
	console.log(data);
	return request({
		url: 'fundRecord/list',
		// url: "wallet/friendTransfer?amount=" + data.amount + '&friendId=' + data.friendId  ,
		data: data,
		method: 'GET'
	})
}

// 校验密码
export function checkPsdApi(data) {
	return request({
		url: 'user/checkPassword?password=' + data,
		data: data,
		method: 'GET'
	})
}

// c2c
export function getTradeOrderConfigInfo(data) {
	return request({
		url: 'tradeOrder/getTradeOrderConfigInfo',
		data: data,
		method: 'GET',
	})
}
// 忘记密码校验助记词
export function forgetCheckPsdApi(data) {
	return request({
		url: 'user/forgetPassword?words=' + data.words,
		data: data,
		method: 'POST'
	})
}

// 充值列表
export function udunCloudListApi(data) {
	return request({
		url: 'uduncloud/list?pageNum=' + data.pageNum + '&pageSize=' + data.pageSize,
		method: 'GET'
	})
}
// 资金划转
export function fundTransfer(data) {
	return request({
		url: 'wallet/fundTransfer?amount=' + data.amount + '&type=' + data.type,
		// data: data,
		method: 'POST'
	})
}

// 交易地址
export function checkAddressApi(data) {
	return request({
		url: 'user/checkAddress',
		method: 'GET'
	})
}

// 兑换种子
export function pointExchange(data) {
	return request({
		url: 'wallet/pointExchange',
		data: data,
		method: 'POST'
	})
}
// 撤销提现
export function cancelApply(data) {
	return request({
		url: 'wapply/cancelApply?applyId=' + data.applyId,
		// data: data,
		method: 'POST'
	})
}

// 留言列表
export function messageListApi() {
	return request({
		url: 'message/messageList',
		method: 'GET'
	})
}

// 添加留言
export function addMessageApi(data) {
	return request({
		url: 'message/saveMessage',
		data: data,
		method: 'POST'
	})
}

// 公告列表
export function noticeListApi() {
	return request({
		url: 'notice/list',
		method: 'GET'
	})
}

// 公告详情
export function noticeDetailApi(data) {
	return request({
		url: 'notice/detail?id=' + data ,
		method: 'GET'
	})
}

// 上传图片
export function uploadImage(data) {
	return new Promise((resolve,reject) => {
		uni.uploadFile({
			url: UNI_APP.BASE_URL + '/upload',
			header: {
				token: uni.getStorageSync("token")
			},
			filePath: data,
			name: 'file',
			success: (res) => {
				resolve(res.data)
			}
		})
	})
}

// 获取APP版本
export function getNewAppInfoAPI() {
	return request({
		url: 'user/getNewAppVersion',
		method: 'GET'
	})
}

// 发布朋友圈
export function postDynamicApi(data) {
	return request({
		url: 'friendCircle/publish',
		data, 
		method: 'POST'
	})
}

// 获取朋友圈
export function friendCircleApi(data) {
	return request({
		url: 'friendCircle/getFriendCircle?pageNum=' + data.pageNum + '&pageSize=' + data.pageSize,
		method: 'GET'
	})
}

// 评论朋友圈
export function commentFriendCircleApi(data) {
	return request({
		url: 'friendCircle/commentFriendCircle',
		data,
		method: 'POST'
	})
}

// 点赞朋友圈
export function linkFriendCircleApi(data) {
	return request({
		url: 'friendCircle/likeFriendCircle?circleId=' + data,
		method: 'POST'
	})
}

// 取消点赞
export function cancelLikeApi(data) {
	return request({
		url: 'friendCircle/cancelLike?circleId=' + data,
		method: 'DELETE'
	})
}

// 获取自己朋友圈
export function getOwnFriendCircleApi(data) {
	return request({
		url: 'friendCircle/getOwnFriendCircle?pageNum=' + data.pageNum + '&pageSize=' + data.pageSize,
		method: 'GET'
	})
}

// 获取好友朋友圈
export function getCircleByFriendIdApi(data) {
	return request({
		url: 'friendCircle/getCircleByFriendId?pageNum=' + data.pageNum + '&pageSize=' + data.pageSize + '&friendId=' + data.friendId,
		method: 'GET'
	})
}

// id查询朋友圈
export function getCirclyByIdApi(data) {
	return request({
		url: 'friendCircle/getCircleById?circleId=' + data,
		method: 'GET'
	})
}

// 修改个人信息
export function updateUserApi(data) {
	return request({
		url: 'user/updateUser',
		data,
		method: 'POST'
	})
}

// 获取用户二维码
export function getQRCodeApi() {
	return request({
		url: 'user/getQRCode',
		method: 'GET'
	})
}

// 好友申请
export function addFriendRequestApi(data) {
	return request({
		url: 'friendRequest/addFriendRequest',
		data,
		method: 'POST'
	})
}

// 好友申请列表
export function friendRequestListApi(data) {
	return request({
		url: 'friendRequest/friendRequestList?pageNum=' + data.pageNum + '&pageSize=' + data.pageSize,
		data,
		method: 'POST'
	})
}

// 通过好友申请
export function friendRequestByRequestApi(data) {
	return request({
		url: 'friendRequest/byRequest?friendId=' + data,
		method: 'POST'
	})
}

// 浏览器列表
export function browserSetListApi() {
	return request({
		url: 'browserSet/list',
		method: 'GET'
	})
}
// 删除朋友圈
export function deleteFriendCircle(data) {
	return request({
		url: 'friendCircle/deleteFriendCircle?circleId=' + data,
		method: 'DELETE'
	})
}
// 修改好友备注
export function friendUpdateNotname(data) {
	return request({
		url: 'friend/update',
		data,
		method: 'PUT'
	})
}
// 分页获取兑换商品
export function getGoodsPage(data) {
	return request({
		url: 'exchangeGoods/getPage',
		data,
		method: 'GET'
	})
}
// 分页获取兑换商品
export function getByGoodsId(data) {
	return request({
		url: 'exchangeGoods/getByGoodsId',
		data,
		method: 'GET'
	})
}
// 分页获取兑换商品
export function exchangeGoodsExchange(data) {
	return request({
		url: 'exchangeGoods/exchange',
		data,
		method: 'POST'
	})
}
// 分页获取兑换商品
export function exchangeGoodsGetOrderPage(data) {
	return request({
		url: 'exchangeGoods/getOrderPage',
		data,
		method: 'GET'
	})
}
// 绑定上级用户
export function bindInviteUser(data) {
	return request({
		url: 'user/bindInviteUser?inviteCode=' + data.inviteCode,
		method: 'POST'
	})
}
// 团队信息
export function inviteList(data) {
	return request({
		url: 'user/inviteList?pageNum=' + data.pageNum + '&pageSize=' + data.pageSize+ '&userId=' + data.userId,
		method: 'GET'
	})
}
// 获取需要扣除的权益积分
export function getDeductionEquityPoints(data) {
	return request({
		url: 'mateTrade/getDeductionEquityPoints',
		data,
		method: 'GET'
	})
}
// 查询用户实名
export function getUserRealName(data) {
	return request({
		url: 'userRealName/getUserRealName',
		data,
		method: 'GET'
	})
}
// 提交实名
export function addUserRealName(data) {
	return request({
		url: 'userRealName/addUserRealName',
		data,
		method: 'POST'
	})
}
// 修改实名
export function updateUserRealName(data) {
	return request({
		url: 'userRealName/updateUserRealName',
		data,
		method: 'POST'
	})
}
// 获取提现手续费
export function getWirhdrawFee(data) {
	return request({
		url: 'wapply/getWirhdrawFee',
		data,
		method: 'GET'
	})
}